#!/bin/bash

echo "build ..."
if [ "local_bundle_mock" = $1 ] ; then
    mvn clean package -pl apiworld-bundle-mock -am -Dbdmgc.skip=false
elif [ "mock_server" = $1 ] ; then
    mvn clean package -pl apiworld-mock-server -am -Dbdmgc.skip=false
    cp apiworld-mock-server/target/apiworld-mock-server.war ~/server/tomcat8/webapps/apiworld-mock-server.war
elif [ "mock_server_sb" = $1 ] ; then
    mvn clean package -pl apiworld-mock-server-sb -am -Dbdmgc.skip=false
    cp apiworld-mock-server-sb/target/apiworld-mock-server-sb.jar ~/app/apiworld/apiworld-mock-server-sb.jar
elif [ "package_api_test" = $1 ] ; then
    mvn clean package -pl apiworld-api-test -am -Dclientgc.skip=false
elif [ "mock_test" = $1 ] ; then
    mvn clean test -pl apiworld-api-test -Dclientgc.skip=false -DlogLevel=$2
elif [ "package_ci" = $1 ] ; then
    mvn clean package -pl apiworld-api -am -Dapigc.skip=false
    mvn clean package -pl apiworld-api-test -am -Dclientgc.skip=false -Dmaven.test.skip=true
    mvn clean package -pl apiworld-bundle -am -Dbdgc.skip=false
    mvn clean package -pl apiworld-api-test -am -Dclientgc.skip=false -Dmaven.test.skip=true
    mvn clean package -pl apiworld-bundle-mock -am -Dbdmgc.skip=false
fi
echo "build done."